home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / hurd / privports.c < prev    next >
C/C++ Source or Header  |  1994-01-20  |  2KB  |  61 lines

  1. /* Copyright (C) 1993, 1994 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. #include <hurd.h>
  20.  
  21. /* The program might set these if it is the initial task
  22.    bootstrapped by the microkernel.  */
  23.  
  24. mach_port_t _hurd_host_priv, _hurd_device_master;
  25.  
  26.  
  27. kern_return_t
  28. get_privileged_ports (host_priv_t *host_priv_ptr, device_t *device_master_ptr)
  29. {
  30.   if (! _hurd_host_priv)
  31.     {
  32.       error_t err;
  33.  
  34.       if (_hurd_ports)
  35.     /* We have gotten some initial ports, so perhaps
  36.        we have a proc server to talk to.  */
  37.     err = __USEPORT (PROC, __proc_getprivports (port,
  38.                             &_hurd_host_priv,
  39.                             &_hurd_device_master));
  40.       else
  41.     return MACH_SEND_INVALID_DEST;
  42.  
  43.       if (err)
  44.     return err;
  45.     }
  46.  
  47.   if (host_priv_ptr)
  48.     {
  49.       mach_port_mod_refs (mach_task_self (),
  50.               _hurd_host_priv, MACH_PORT_RIGHT_SEND, 1);
  51.       *host_priv_ptr = _hurd_host_priv;
  52.     }
  53.   if (device_master_ptr)
  54.     {
  55.       mach_port_mod_refs (mach_task_self (),
  56.               _hurd_device_master, MACH_PORT_RIGHT_SEND, 1);
  57.       *device_master_ptr = _hurd_device_master;
  58.     }
  59.   return KERN_SUCCESS;
  60. }
  61.